articles

Home / DeveloperSection / Articles / Conjunctions and Dis-junctions in SQL Server

Conjunctions and Dis-junctions in SQL Server

Conjunctions and Dis-junctions in SQL Server

Sachindra Singh 49330 12-Feb-2011

Conjunctions and Disjunctions in SQL Server

The Conjunctions

Basically the logical conjunction is used to check that two conditions are true, in logical conjunction both conditions must be verified.

In logical conjunction, if either condition is false, the whole statement is false. For instance, you have a list of students and you want to study some statistics for your database.

You want to get a list of girls, you can filter the students based on the gender and girl’s age should be greater than 20.

I have an Employee table and I will use this table to perform an operation.

Conjunctions and Dis-junctions in SQL Server

To create logical conjunction in SQL Server, we use the AND operator to combine two conditions. The formula to follow is:

  Query
select * from Emp
where Gender='Female' 
and Age>20
 Output

Conjunctions and Dis-junctions in SQL Server

Disjunctions 

A logical disjunction can be performed in one field. Interpreter to find out if the field matches this or that value.

In logical disjunction, if one condition is true than the query will be executed, if the first condition is false then the OR keyword check next condition is true or not if

the condition is true query will be executed. For instance, I have one condition I want to see that record of the person who belongs to Allahabad or Varanasi city.

I have a StudentDetail table and I will use this table to perform the operation.

Conjunctions and Dis-junctions in SQL Server


To create a logical disjunction in SQL Server, we use the OR operator to combine two conditions. The formula to follow is:

Query
select *
from StudentDetail where City='Allahabad'
or City='Varanasi'
Output

Conjunctions and Dis-junctions in SQL Server

 


Updated 04-Mar-2020

Leave Comment

Comments

Liked By